<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>地点展示</title>
    <link href="/css/global.css" rel="stylesheet" type="text/css">
    <link href="all/mapSelector.css" rel="stylesheet" type="text/css">
</head>
<body>
    <div class="main">
        <div class="mtr">
            <div class="one">
                <div class="header">
                    <span>地理信息查看</span>
                    <i class="icon iconfont icon-close"></i>
                </div>
                <div id="container" class="vessel"></div>
                <div class="btnBox" style="height: auto;text-align: left;">
                    <div class="tip">
                        <span style="font-weight: bold;">位置：</span>
                        <label>--</label>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="../jquery-1.11.1.min.js"></script>
    <script src="../config.js"></script>
    <script src="../ly_main.js"></script>
    <script src="../gps.js"></script>
    <script src="//api.map.baidu.com/getscript?v=2.0&ak=6NSf3ER1QWCV8HuCIDVVwLrslmRHjD65&services=&t=20171031174121"></script>
    <script type="text/javascript">
        //初始化地图marker的信息
        var inInfo = parent.$('.showMapSelector-iframe').attr('ininfo');
        var map = new BMap.Map("container");    // 创建地图实例
        var point = new BMap.Point(106.53063501,29.54460611);  // 创建点坐标
        var infoFlag = '';                            //详细地址
        var marker = new BMap.Marker(point),nowPoint = {lng:'',lat:''};          //地图地点标记和经纬度
        if(inInfo && inInfo != '{}') {
            var jsonData = JSON.parse(inInfo);
            if(jsonData.lng && jsonData.lat) {
                var gdtodb = GPS.bd_encrypt(jsonData.lat,jsonData.lng)
                var inPoint = new BMap.Point(gdtodb.lon,gdtodb.lat);
                marker = new BMap.Marker(inPoint);
                addMarker(inPoint);
                infoFlag = jsonData.address;
                $(".tip label").val(infoFlag);
                nowPoint = inPoint;
                map.centerAndZoom(inPoint, 15);
            } else {
                map.centerAndZoom(point, 15); 
            }
        } else {
            map.centerAndZoom(point, 15);                 // 初始化地图，设置中心点坐标和地图级别
        }
        map.enableScrollWheelZoom();   //启用滚轮放大缩小，默认禁用
        map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用
        // 设置标注
        function addMarker(point){
            map.clearOverlays();
            marker = new BMap.Marker(point);
            map.addOverlay(marker);
        }
        $('.header i').click(function(){
            parent.$('.showMapSelector-iframe').remove();
        });

    var geolocation = new BMap.Geolocation();
    geolocation.getCurrentPosition(function(r){
        if(this.getStatus() == BMAP_STATUS_SUCCESS){
            var mk = new BMap.Marker(r.point);
            map.addOverlay(mk);
            map.panTo(r.point);
        }
    })
    </script>
</body>
</html>
